using UnityEngine;
using System.Collections;

public class Blocker : Ennemy
{

	public AudioClip ambientSound;
	
	public GameObject UpperFiringPos;
	public GameObject LowerFiringPos;
	
	public float FiringTime = 2.0f;
	
	private float mNextFire;
	
	protected override void PostSpawnProcess ()
	{
		transform.position = new Vector3(transform.position.x, mWalkableRect.Bottom, transform.position.z);
		mNextFire = 0;
		
		GetComponent<EnnemySound>().SetAmbient(ambientSound, 1.0f, 1.0f, 0.7f);
	}
	
	protected void Update()
	{
		mNextFire += Time.deltaTime;
		if(mNextFire > FiringTime)
		{
			mNextFire = 0;
			GameObject lBullet = Resources.Load("bullet") as GameObject;
			
			GameObject lInst;

			lInst = Instantiate(lBullet, UpperFiringPos.transform.position, lBullet.transform.rotation) as GameObject;
			
			Bullet lBulletScr = lInst.GetComponent<Bullet>();
			lBulletScr.acc_sensRight = false;
			lBulletScr.acc_playerOwned = false;
			
			
			lInst = Instantiate(lBullet, LowerFiringPos.transform.position, lBullet.transform.rotation) as GameObject;
			
			lBulletScr = lInst.GetComponent<Bullet>();
			lBulletScr.acc_sensRight = false;
			lBulletScr.acc_playerOwned = false;
		}
	}
}
